﻿using System;
using Autodesk.Revit.DB;
using YJKRGeometry;

namespace YJKCoordinate
{
	public class SlopDataInfo
	{
		public XYZ ThisLocation
		{
			get
			{
				return this.m_thisLocation;
			}
			private set
			{
				this.m_thisLocation = value;
			}
		}

		public XYZ ThisDriection
		{
			get
			{
				return this.m_thisDriection;
			}
			private set
			{
				this.m_thisDriection = value;
			}
		}

		public double ThisValue
		{
			get
			{
				return this.m_thisValue;
			}
			private set
			{
				this.m_thisValue = value;
			}
		}

		public SlopDataInfo(XYZ location, XYZ driection, double value)
		{
			this.ThisLocation = location;
			this.ThisDriection = driection;
			this.ThisValue = value;
		}

		public override string ToString()
		{
			return string.Concat(new string[]
			{
				this.m_thisLocation.ToString(),
				";",
				this.m_thisDriection.ToString(),
				";",
				this.m_thisValue.ToString()
			});
		}

		public static bool TryParse(string inputStr, out SlopDataInfo creatValue)
		{
			creatValue = null;
			if (string.IsNullOrEmpty(inputStr))
			{
				return false;
			}
			string[] array = inputStr.Split(new char[]
			{
				';'
			});
			if (array.Length != 3)
			{
				return false;
			}
			bool result;
			try
			{
				XYZ location = null;
				if (!DataSerializeDeserialize.StringToPoint(array[0], out location))
				{
					result = false;
				}
				else
				{
					XYZ driection = null;
					double value;
					if (!DataSerializeDeserialize.StringToPoint(array[1], out driection))
					{
						result = false;
					}
					else if (!double.TryParse(array[2], out value))
					{
						result = false;
					}
					else
					{
						creatValue = new SlopDataInfo(location, driection, value);
						result = true;
					}
				}
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		private XYZ m_thisLocation;

		private XYZ m_thisDriection;

		private double m_thisValue;
	}
}
